#include <iostream>
using namespace std;

class MyInteger {
    friend ostream& operator<<(ostream & out , const MyInteger& n);
public:
    MyInteger() {
        m_num = 0;
    }
    //前置--
    MyInteger& operator--() {
        m_num--;
        return *this;
    }
    //后置--
    MyInteger operator--(int) {
        //用一个变量来接收原值
        MyInteger temp = *this;
        //--
        m_num--;
        //返回
        return temp;
    }

private:
    int m_num;
};
//因为 n-- 是临时对象，无法绑定到非常量引用。加上 const 后 ， 编译器允许绑定到常量引用。
ostream& operator<<(ostream & out , const MyInteger& n){
    out << n.m_num;
    return out;
}

void test01() {
    MyInteger n;
    cout << --n << endl;
    cout << n << endl;
}
void test02() {
    MyInteger n;
    cout << n-- << endl;
    cout << n << endl;
}
int main() {
    //test01();
    test02();
    return 0;
}